﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MathLab.Messaging;

namespace MathLab.Parsing
{
    /// <summary>
    /// Parser for specific commands (transpose, reversing) .
    /// </summary>
    class ArraySpecificCommandParser
    {
        protected string _resultArrayName;

        protected string _firstArrayName;

        public void parse(string input)
        {
            StringBuilder name = new StringBuilder();

            for (int i = 0; i < input.Length; i++)
            {
                string s = input[i].ToString();
                
                switch (s)
                {
                    case Literals.EQUALS:
                        resultArrayName = name.ToString();
                        name = new StringBuilder();
                        break;
                    case "(":
                        name = new StringBuilder();
                        break;
                    case ")":
                        continue;
                    default:
                        name.Append(s);                   
                        break;
                }
            }

            firstArrayName = name.ToString();
        }

        public string resultArrayName
        {
            get
            {
                return _resultArrayName;
            }
            set
            {
                _resultArrayName = value;
            }
        }

        public string firstArrayName
        {
            get
            {
                return _firstArrayName;
            }
            set
            {
                _firstArrayName = value;
            }
        }
    }
}
